//
//  FileUtils.h
//  tableViewLazyDemo
//
//  Created by kingboyrang on 2021/11/20.
//  Copyright © 2021 wulanzhou. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface FileUtils : NSObject

//缓存图片
+ (void)cacheImage:(NSData *)data key:(NSString *)urlStr;

//获取缓存图片
+ (UIImage *)getCacheImageForKey:(NSString *)urlStr;

/// 图片按比例缩放
/// @param sourceImage 要缩放的图片
/// @param size        图片显示到多大区域
+ (UIImage *) imageFitSizeScale:(UIImage *)sourceImage targetSize:(CGSize)size;


/// 图片指定宽度按比例缩放
/// @param sourceImage 要缩放的图片
/// @param defineWidth 图片显示到多大的宽度
+ (UIImage *) imageForWidthScale:(UIImage *)sourceImage targetWidth:(CGFloat)defineWidth;


/// 图片压缩(压缩图片质量与大小相结合)
/// @param image       要压缩的图片
/// @param maxLength   最大文件大小(kb)
+ (UIImage *)compressImage:(UIImage *)image toByte:(NSUInteger)maxLength;

@end

NS_ASSUME_NONNULL_END
